package cn.edu.tju.elm.repository;

import cn.edu.tju.elm.model.BusinessApplication;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface BusinessApplicationRepository extends JpaRepository<BusinessApplication, Long> {

    // 根据申请人ID查询开店申请
    List<BusinessApplication> findByApplicantIdOrderByCreateTimeDesc(Long applicantId);

    // 根据状态查询开店申请
    List<BusinessApplication> findByStatusOrderByCreateTimeDesc(Integer status);

    // 根据申请人ID和状态查询开店申请
    List<BusinessApplication> findByApplicantIdAndStatusOrderByCreateTimeDesc(Long applicantId, Integer status);

    // 统计待审核申请数（状态为0）
    long countByStatus(Integer status);

    Optional<BusinessApplication> findByIdAndApplicantId(Long id, Long applicantId);
}
